# {表达式 for 迭代变量 in 可迭代对象 [if 条件表达式]}


listdemo = ['C辣辣', 'main.icanci.cn']
# 将列表中各字符串值为键，各字符串的长度为值，组成键值对
newdict = {key: len(key) for key in listdemo}
print(newdict)  # {'C辣辣': 3, 'main.icanci.cn': 14}

olddict = {'C辣辣': 6, 'main.icanci.cn': 14}
newdict = {v: k for k, v in olddict.items()}
print(newdict)  # {6: 'C辣辣', 14: 'main.icanci.cn'}
